<?php

	include "../controller/ConectBanco.php";

class StatusDAO{
		
	function delete($idstatus){
		$result = mysql_query("SELECT idDevice FROM status WHERE idstatus = $idstatus")or die (mysql_error());
		$iddevice = mysql_fetch_array($result);
		mysql_query("DELETE FROM status WHERE idstatus =".$idstatus) or die (mysql_error());	
	
		header("location:../view/ListaStatus.php?idDevice=".$iddevice['idDevice']);
	}
	
	function update(Status $status){
		
		 mysql_query("UPDATE `localizagora`.`status` SET `combustEletric`='".$status->getCombustEletric()."'
		 											   , `tracking`='".$status->getTracking()."'
		 											   , `alarm`='".$status->getAlarm()."'
		 											   , `charge`='".$status->getCharge()."'
		 		                                       , `acc`='".$status->getAcc()."'
		 		                                       , `voltage`='".$status->getVoltage()."'
		 		                                       , `signal`='".$status->getSignal()."'
		 		                                       , `realDateTime`='".$status->getRealDateTime()."'
		 		                                       , `dateTime`='".$status->getDateTime()."' 
		 		                                       WHERE `idStatus`='".$status->getIdStatus()."';") or die (mysql_error());  
									  
								  
	
		header("location:../view/ListaStatus.php?idDevice=".$status->getIdDevice());
	}
}	
	
?>